package com.whl;

import javax.sql.DataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.whl.mybatis.config.EnabledWhlMybatis;

@EnabledWhlMybatis
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = "com.whl")
@EnableScheduling
@EnableTransactionManagement
@EnableDiscoveryClient
public class Application {
	private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
	@Bean
	public PlatformTransactionManager txManager(DataSource dataSource) {
		return new DataSourceTransactionManager(dataSource);
	}
	public static void main(String[] args) throws Exception {
		long startTime = System.currentTimeMillis();
		SpringApplication.run(Application.class, args);
		long endTime = System.currentTimeMillis();
		LOGGER.debug("application finish start ,cost:" + (endTime - startTime) / 1000 + "s");
	}

}
